package task;

public class Test2 {
    public static void main(String[] args) throws InterruptedException {
        Thread[] arr = new Thread[20];
        for (int i = 0; i < 20; i++) {
            final int n = i;
            arr[i] = new Thread(() -> {
                System.out.println(n);
            });
            arr[i].start();
        }
        for (int i = 0; i < 20; i++) {
            arr[i].join();
        }
        System.out.println("ok");
    }
}
